package com.aaa.ni.controller;

import com.aaa.common.entity.News;
import com.aaa.common.util.Constants;
import com.aaa.common.util.Result;
import com.aaa.common.vo.NewsVo;
import com.aaa.ni.service.IUserInfoService;
import com.aaa.ni.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * fileName:NewsController
 * description:
 *
 * @author:wzl createTime:2020/9/3 15:42
 */

@RestController
@RequestMapping("news")
public class NewsController {

    @Autowired
    private NewsService newsService;


    /**
     * 分页查询
     * @param pageNo
     * @param pageSize
     * @param map
     * @return
     */
    @PostMapping("pageByParam")
    public Result pageByParam(Integer pageNo, Integer pageSize, @RequestBody Map map){
        return newsService.pageByParam(pageNo,pageSize,map);
    }

    @GetMapping("deleteByPrimaryKey")
    public Result deleteByPrimaryKey(Integer id){
        return new Result(Constants.RESULT.SUCCESS,Constants.RESULT.SUCMESSAGE,newsService.deleteByPrimaryKey(id));
    }

    @PostMapping("insertSelective")
    public Result insertSelective(@RequestBody NewsVo newsVo , String accessToken){
        return new Result(Constants.RESULT.SUCCESS,Constants.RESULT.SUCMESSAGE,newsService.insertSelective(newsVo,accessToken));
    }
    @GetMapping("selectByPrimaryKey")
    public Result selectByPrimaryKey(Integer id, String accessToken,Integer isBack){
        return new Result(Constants.RESULT.SUCCESS,Constants.RESULT.SUCMESSAGE,newsService.selectByPrimaryKey(id,accessToken,isBack));
    }

    @PutMapping("updateByPrimaryKeySelective")
    public Result updateByPrimaryKeySelective(News record){
        return new Result(Constants.RESULT.SUCCESS,Constants.RESULT.SUCMESSAGE,newsService.updateByPrimaryKeySelective(record));
    }

}
